package com.ui.mine.view;

import android.content.res.TypedArray;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;

import com.base.BaseContract;
import com.base.BaseSlideOutActivity;
import com.ddd.wandemo.R;
import com.ui.home.adapter.HomeFragmentTabAdapter;
import com.ui.home.view.HomeProjectFragment;
import com.widget.CustomViewPager;
import com.widget.ShortIndicatorTabLayout;

import java.util.ArrayList;
import java.util.List;

public class TodoDetailActivity extends BaseSlideOutActivity {
    private Toolbar mToolbar;
    private CustomViewPager mVpTodo;
    private ShortIndicatorTabLayout mTlTodoFrag;
    private String[] tabs = {"已完成", "未完成"};
    private List<Fragment> mFragments = new ArrayList<>();
    @Override
    protected int setLayoutId() {
        return R.layout.activity_user_detail;
    }

    @Override
    protected void initView() {
        mToolbar = findViewById(R.id.toolbar);
        mVpTodo = findViewById(R.id.vp_todo);
        mTlTodoFrag = findViewById(R.id.tl_home_frag);
        initToolBar();
    }

    @Override
    protected void initEvent() {
        TodoFragment todoFragment = new TodoFragment();
        mFragments.add(todoFragment);
        mFragments.add(new HomeProjectFragment());

        HomeFragmentTabAdapter tabAdapter = new HomeFragmentTabAdapter(getSupportFragmentManager(), mFragments, tabs);
        mVpTodo.setAdapter(tabAdapter);
        mTlTodoFrag.setupWithViewPager(mVpTodo);
    }

    private void initToolBar() {
        mToolbar.setTitle("TODO");
        //根据主题设置返回键
        TypedArray array = getTheme().obtainStyledAttributes(new int[]{
                R.attr.back_icon
        });
        int backIcon = array.getResourceId(0,

                0);

        mToolbar.setNavigationIcon(backIcon);
        setSupportActionBar(mToolbar);
        getSupportActionBar().setHomeButtonEnabled(true); //设置返回键可用
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    @Override
    protected BaseContract.RootPresenter initPresenter() {
        return null;
    }
}
